//======================================================================================
//  Apache License, Version 2.0
//  Notes:Use this command to anonymously check out the latest project source code:
//  Non-members may check out a read-only working copy anonymously over HTTP.
//  SVN checkout http://YHHLineCreateByGsdWsp.googlecode.com/svn/trunk/ 
//
//  Author:		Kevin Yang
//  Email:		Bigearrabbit@qq.com
//
//  DATE:		2013-4-6
//
//  File Name:	
//
//  Notes:
//
//======================================================================================
#ifndef YHHLineCreateByGsdCmd_H
#define YHHLineCreateByGsdCmd_H
//Local Framework
#include "YHHLineCreateByGsdCore.h"
#include "YHHLineCreateByGsdParam.h"
#include "YHHLineCreateByGsdDlg.h"

// MechanicalModelerUI Framework
#include "CATMMUIPanelStateCmd.h"   // Needed to derive from CATMMUIPanelStateCmd

//pre-declare class
class YHHILineCreateByGsd;
class CATFeatureImportAgent;
class CATISpecObject;
class CATHSO;
class CATIGSMTool;
class CATIPrtPart;
class CATDialogState;

/**
* Class managing the dialog command to edit Line Create By GSDs.
* 
* refer to programming resources of MechanicalModelerUI framework.
* (consult base class description).
*/
class YHHLineCreateByGsdCmd: public CATMMUIPanelStateCmd
{

public://base


	/// <summary>Standard constructor </summary>
	/// <param name="ipInstance">input instance</param>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-10</date>
	YHHLineCreateByGsdCmd ( YHHILineCreateByGsd *ipInstance  = NULL );

	/// <summary>Standard destructor</summary>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-10</date>
	virtual ~YHHLineCreateByGsdCmd ();

	/// <summary>Build Graph</summary>
	void BuildGraph();

public://property

	/// <summary>param pointer define</summary>
	/// <remarks></remarks>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-7</date>
	YHHPropertyDefinePointerGetGet(ParamGsd,YHHLineCreateByGsdParam);

	/// <summary>Core pointer define</summary>
	/// <remarks></remarks>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-7</date>
	YHHPropertyDefinePointerGetGet(Core,YHHLineCreateByGsdCore);

public: //system function

	/// <summary>Action for Cancel</summary>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-7</date>
	CATBoolean CancelAction(void *);

	/**
	* Returns a different value whether the command is used to create or edit a Line Create By GSD.
	* This parameter is used by CATMMUIPanelStateCmd services.
	*/
	int GetMode(); 
	/**
	* Returns the featurebeing created or edited
	* This parameter is used by CATMMUIStateCmd services.
	*/
	CATISpecObject_var GiveMyFeature();

	/**
	* Returns a pointer to the dialog panel.
	* This pointer is used by CATMMUIPanelStateCmd services.
	*/
	CATDlgDialog* GiveMyPanel();

	/// <summary>Action for OK</summary>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-7</date>
	CATBoolean OkAction(void *);

	/// <summary>Action for Preview</summary>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-7</date>
	CATBoolean PreviewAction(void *);

public: //user function

	/// <summary>Method called when LineDirection is selected</summary>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-6</date>
	CATBoolean ActionElemSelLineDirection(void *);

	/// <summary>Method called when StartPoint is selected</summary>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-6</date>
	CATBoolean ActionElemSelStartPoint(void *);

	/// <summary>Method called when the field LineDirection is selected</summary>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-6</date>
	CATBoolean ActionFieldSelLineDirection(void *);

	/// <summary>Method called when the field StartPoint is selected</summary>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-6</date>
	CATBoolean ActionFieldSelStartPoint(void *);

	/// <summary>Method called when Value Change</summary>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-7</date>
	CATBoolean ActionValueChange(void *);

	/// <summary>Element Selected</summary>
	/// <param name="ipAgent">CATFeatureImportAgent</param>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-6</date>
	void AfterElementSelected(CATFeatureImportAgent *ipAgent);

	/// <summary>called after value changed</summary>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-7</date>
	void AfterValueChange();

	/// <summary>CATFeatureImportAgent Clear</summary>
	/// <remarks></remarks>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-7</date>
	void fiaAgentClear();

	/// <summary>CATFeatureImportAgent Clear</summary>
	/// <remarks></remarks>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-7</date>
	void fiaAgentUpdate();

	/// <summary>Asks the panel to focus on an Active Field</summary>
	/// <param name="iActiveField">Active Field</param>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-6</date>
	void SetActiveField(YHHLineCreateByGsdField iActiveField);

private : //Prevent Use function

	// Default Constructor, Copy constructor and equal operator, to prevent reimplementation
	// ----------------------------------------------------------------
	YHHLineCreateByGsdCmd (YHHLineCreateByGsdCmd &);
	YHHLineCreateByGsdCmd& operator=(YHHLineCreateByGsdCmd&);
private : //system function

	// Manage the current feature in case of ordered and linear body
	//
	CATStatusChangeRC Activate   (CATCommand * iCmd,CATNotification * iNotif);
	CATStatusChangeRC Cancel   (CATCommand * iCmd,CATNotification * iNotif);

	CATStatusChangeRC Deactivate   (CATCommand * iCmd,CATNotification * iNotif);
private ://user function

	/// <summary>Manage the Line Create By GSD creation</summary>
	/// <remarks></remarks>
	/// <author>Kevin Yang</author>
	/// <date>2013-4-6</date>
	HRESULT CreateElement() ;

	// Checks if the Line Create By GSDd is inside an Ordered Geometrical Set
	HRESULT IsLineCreateByGsdInsideOrderedBody(CATBoolean & oIsInsideOrderedBody ) ;

private ://variable

	CATISpecObject_var					_spSpecObjOnPreviousCurrentFeat ; //Previous Element
	CATDialogState					*	_InitialState;		// For Initial State
	CATFeatureImportAgent			*	_pfiaStartPoint  ;	//for fia StartPoint
	CATFeatureImportAgent			*	_pfiaLineDirection ;//for fia LineDirection

	CATDialogAgent					*	_pdaStartPoint;		//for field StartPoint
	CATDialogAgent					*	_pdaLineDirection;	//for Field LineDirection
	CATDialogAgent					*	_pdaValueChange ;	//for value change

	YHHLineCreateByGsdDlg			*	_pMainDlg;			//Main Dialog

	CATFrmEditor					*	_editor;			//Editor

	CATHSO							*	_HSO;				// HSO

	int									_mode;				//Edit mode
};

#endif
